package com.shenjies88.practice.mcpclient.controller;

import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author by shenjies88
 * @since 2025/9/13 19:26
 */
@Slf4j
@AllArgsConstructor
@RequestMapping("/chatClient")
@RestController
public class ChatClientController {

    @Resource(name = "qwen3ChatClient")
    private final ChatClient qwen3ChatClient;

    @GetMapping("/chat")
    public String chat(@RequestParam String msg) {
        ChatClient.CallResponseSpec call = qwen3ChatClient.prompt()
                .user(msg)
                .call();
        return call.content();
    }

}
